package com.vhall.component.controller.subject;


import com.alibaba.fastjson.JSONObject;
import com.vhall.component.controller.subject.facade.SubjectConsoleFacade;
import com.vhall.component.entity.subject.vo.*;
import com.vhall.component.framework.common.annotation.VhallComponent;
import com.vhall.component.plugin.common.annotation.TokenAuth;
import com.vhall.component.plugin.common.annotation.UrlDisable;
import com.vhall.component.plugin.common.support.Token;
import com.vhall.component.plugin.common.support.TokenThreadLocal;
import com.vhall.component.service.subject.SubjectConsoleService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author jian.yang
 * @date 2022/3/31 16:19
 */
@VhallComponent
@TokenAuth
@UrlDisable
public class SubjectConsoleController implements SubjectConsoleFacade {

    @Autowired
    SubjectConsoleService subjectConsoleService;

    @Override
    public Boolean create(CreateSubjectVo reqVo) {
        Token token = TokenThreadLocal.getToken();
        Integer accountId = token.getAccountId();
        reqVo.setAccountId(accountId);
        return subjectConsoleService.create(reqVo);
    }

    @Override
    public Boolean update(UpdateSubjectVo reqVo) {
        Token token = TokenThreadLocal.getToken();
        Integer accountId = token.getAccountId();
        reqVo.setAccountId(accountId);
        return subjectConsoleService.update(reqVo);
    }

    @Override
    public JSONObject list(SubjectListReqVo reqVo) {
        Token token = TokenThreadLocal.getToken();
        Integer accountId = token.getAccountId();
        reqVo.setAccountId(accountId);
        return subjectConsoleService.list(reqVo);
    }

    @Override
    public Boolean del(SubjectIdsReqVo reqVo) {
        Token token = TokenThreadLocal.getToken();
        Integer accountId = token.getAccountId();
        reqVo.setAccountId(accountId);
        return subjectConsoleService.del(reqVo);
    }

    /**
     * 获取可以关联的房间
     *
     * @return
     */
    @Override
    public JSONObject getRoomList(SubjectRoomListReqVo subjectRoomListReqVo) {
        Token token = TokenThreadLocal.getToken();
        Integer accountId = token.getAccountId();
        subjectRoomListReqVo.setAccountId(accountId);
        return subjectConsoleService.getRoomList(subjectRoomListReqVo);
    }

    /**
     * 获取会议专题的详情
     *
     * @return
     */
    @Override
    public JSONObject getInfo(SubjectBasicReqVo reqVo) {
        Token token = TokenThreadLocal.getToken();
        Integer accountId = token.getAccountId();
        reqVo.setAccountId(accountId);
        return subjectConsoleService.getInfo(reqVo);
    }


}
